/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.gmao.entities;

import java.io.Serializable;
import java.math.BigInteger;
import java.util.List;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author Amine
 */
@Entity
@Table(name = "consommable")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Consommable.findAll", query = "SELECT c FROM Consommable c"),
    @NamedQuery(name = "Consommable.findByNomCons", query = "SELECT c FROM Consommable c WHERE c.nomCons = :nomCons"),
    @NamedQuery(name = "Consommable.findByQuantite", query = "SELECT c FROM Consommable c WHERE c.quantite = :quantite"),
    @NamedQuery(name = "Consommable.findByIdentCons", query = "SELECT c FROM Consommable c WHERE c.identCons = :identCons")})
public class Consommable implements Serializable {
    private static final long serialVersionUID = 1L;
    @Size(max = 1)
    @Column(name = "nom_cons")
    private String nomCons;
    @Column(name = "quantite")
    private BigInteger quantite;
    @Id
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 10)
    @Column(name = "ident_cons")
    private String identCons;
    @OneToMany(mappedBy = "identCons")
    private List<InterCons> interConsList;

    public Consommable() {
    }

    public Consommable(String identCons) {
        this.identCons = identCons;
    }

    public String getNomCons() {
        return nomCons;
    }

    public void setNomCons(String nomCons) {
        this.nomCons = nomCons;
    }

    public BigInteger getQuantite() {
        return quantite;
    }

    public void setQuantite(BigInteger quantite) {
        this.quantite = quantite;
    }

    public String getIdentCons() {
        return identCons;
    }

    public void setIdentCons(String identCons) {
        this.identCons = identCons;
    }

    @XmlTransient
    public List<InterCons> getInterConsList() {
        return interConsList;
    }

    public void setInterConsList(List<InterCons> interConsList) {
        this.interConsList = interConsList;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (identCons != null ? identCons.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Consommable)) {
            return false;
        }
        Consommable other = (Consommable) object;
        if ((this.identCons == null && other.identCons != null) || (this.identCons != null && !this.identCons.equals(other.identCons))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "com.gmao.entities.Consommable[ identCons=" + identCons + " ]";
    }
    
}
